// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

namespace SnapObjects.Data
{
    /// <summary>
    ///     Represents an object which uses the AND or OR logical operator and adds a search condition in the WHERE clause of a SQL statement.
    ///     The return values of all methods are always the current ISqlWhereAndOr object.
    /// </summary>
    public interface ISqlWhereAndOr : ISqlWhereAndOr<ISqlWhereAndOr>, ISqlGroupBuilder
    {

    }

    /// <summary>
    ///     Represents an object which uses the AND or OR logical operator and adds a search condition in the WHERE clause of a SQL statement.
    ///     The return values of all methods are always the current ISqlWhereAndOr object.
    /// </summary>
    /// <typeparam name="TBuilder"></typeparam>
    public interface ISqlWhereAndOr<TBuilder>
    {
        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and specifies a SQL expression on the left of the operator
        ///     and a specific value on the right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">An expression on the left of the operator.</param>
        /// <param name="value">A specific value on the right of the operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhereValue(string left, object value);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and specifies a SQL expression on the 
        ///     left of the operator and a specific value on the right of the operator.
        /// </summary>
        /// <param name="left">An expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the expression on the left and the value on the right.
        /// </param>
        /// <param name="value">
        ///     The specific value on the right of the operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhereValue(string left, SqlBinaryOperator sqlOperator, object value);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and specifies a SQL expression 
        ///     on the left of the operator and a SQL parameter on the right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="parameter">
        ///     An ISqlParameter object which represents a SQL parameter on the right of the operator.  
        ///     It can be created by calling the SqlBuilder.Parameter method.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhere(string left, ISqlParameter parameter);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and specifies a SQL expression 
        ///     to the left of the operator and a SQL parameter to the right of the operator.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="parameter">
        ///     An ISqlParameter object which represents a SQL parameter on the right of the operator. 
        ///     It can be created by calling the SqlBuilder.Parameter method.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhere(string left, SqlBinaryOperator sqlOperator, ISqlParameter parameter);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and specifies SQL expressions
        ///     on both the left and right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="right">A SQL expression on the right of the operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhere(string left, string right);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and specifies SQL expressions
        ///     on both the left and right of the operator.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="right">A SQL expression on the right of the operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhere(string left, SqlBinaryOperator sqlOperator, string right);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and specifies a SQL
        ///     expression on the left of the operator and a SQL subquery on the right. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlBuilder">
        ///     An ISqlBuilder object which represents a SQL subquery on the right of the operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhere(string left, ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and specifies a SQL expression 
        ///     on the left of the operator and a SQL subquery on the right.
        /// </summary>
        /// <param name="left">
        ///     A SQL expression on the left of the operator.
        /// </param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="sqlBuilder">
        ///     An ISqlBuilder object which represents a SQL subquery on the right of the operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhere(string left, SqlBinaryOperator sqlOperator, ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Adds the AND logical operator and a search condition (specified by an ISqlWhereCondition object) to the WHERE clause.
        /// </summary>
        /// <param name="condition">
        ///     An ISqlWhereCondition which represents a search condition in the WHERE Clause. 
        ///     This object can be created by using the SqlBuilder.Where method and so on.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhere(ISqlWhereCondition condition);

        /// <summary>
        ///     Adds the AND logical operator and a raw SQL to the WHERE clause.
        /// </summary>
        /// <param name="clause">A string of raw SQL to be added to the WHERE clause.</param>
        /// <param name="parameters">
        ///     (Optional) An array of ISqlParameter objects which define the SQL parameters used in the raw SQL.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhereRaw(string clause, params ISqlParameter[] parameters);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and uses IS NULL
        ///     operator to search for values that are null.
        /// </summary>
        /// <param name="left">
        ///     A SQL expression on the left of the IS NULL operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhereIsNull(string left);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and uses IS NOT NULL 
        ///     operator to search for values that are not null.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the IS NOT NULL operator.</param>
        /// <returns>
        ///     Returns the ISqlWhereAndOr object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhereIsNotNull(string left);

        /// <summary>
        ///     Adds the AND logic operator and a search condition to the WHERE clause; and uses EXISTS to test for 
        ///     the existence of the record returned from a subquery.
        /// </summary>
        /// <param name="sqlBuilder">
        ///     An ISqlBuilder object which represents a SQL subquery on the right of the EXISTS operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhereExists(ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Adds the AND logical operator and a search condition to the WHERE clause; and uses the NOT EXISTS operator
        ///     to test if the record returned from a subquery does not exist.
        /// </summary>
        /// <param name="sqlBuilder">
        ///     An ISqlBuilder object which represents a SQL subquery on the right of the NOT EXISTS operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder AndWhereNotExists(ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and specifies a SQL expression on the 
        ///     left the operator and a specific value on the right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">An expression on the left of the operator.</param>
        /// <param name="value">The specific value on the right of the operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhereValue(string left, object value);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and specifies a SQL expression 
        ///     on the left the operator and a specific value on the right of the operator.
        /// </summary>
        /// <param name="left">An expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the expression on the left and the value on the right.
        /// </param>
        /// <param name="value">The specific value on the right of the operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhereValue(string left, SqlBinaryOperator sqlOperator, object value);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and specifies a SQL expression to the 
        ///     left of the operator and a SQL parameter to the right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="parameter">
        ///     An ISqlParameter object which represents a SQL parameter. 
        ///     It can be created by calling the SqlBuilder.Parameter method.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhere(string left, ISqlParameter parameter);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and specifies a SQL expression
        ///     on the left of the operator and a SQL parameter on the right of the operator.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="parameter">
        ///     An ISqlParameter object which represents a SQL parameter. 
        ///     It can be created by calling the SqlBuilder.Parameter method.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhere(string left, SqlBinaryOperator sqlOperator, ISqlParameter parameter);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and specifies SQL expressions
        ///     on both the left and right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="right">A SQL expression on the right of the operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhere(string left, string right);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and specifies SQL expressions 
        ///     on both the left and right of the operator.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="right">A SQL expression on the right of the operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhere(string left, SqlBinaryOperator sqlOperator, string right);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and specifies a SQL expression on 
        ///     the left of the operator and a SQL subquery on the right. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlBuilder">
        ///     An ISqlBuilder object which represents a SQL subquery on the right of the operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhere(string left, ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and specifies a SQL expression 
        ///     on the left of the operator and a SQL subquery on the right.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="sqlBuilder">
        ///     An ISqlBuilder object which represents a SQL subquery on the right of the operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhere(string left, SqlBinaryOperator sqlOperator, ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Adds the OR logical operator and a search condition (specified by an ISqlWhereCondition object) to the WHERE clause.
        /// </summary>
        /// <param name="condition">
        ///     An ISqlWhereCondition which represents a search condition for WHERE clause. 
        ///     This object can be created by using the SqlBuilder.Where method and so on.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhere(ISqlWhereCondition condition);

        /// <summary>
        ///     Adds the OR logical operator and a raw SQL to the WHERE clause.
        /// </summary>
        /// <param name="clause">
        ///     A string of raw SQL to be added to the WHERE clause.
        /// </param>
        /// <param name="parameters">
        ///     (Optional) An array of ISqlParameter objects which define the SQL parameters used in the raw SQL.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhereRaw(string clause, params ISqlParameter[] parameters);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; 
        ///     and uses IS NULL operator to search for values that are null.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the IS NULL operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhereIsNull(string left);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and uses the 
        ///     IS NOT NULL operator to search for values that are not null.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the IS NOT NULL operator.</param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhereIsNotNull(string left);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and uses EXISTS to test for
        ///     the existence of the record returned from a subquery.
        /// </summary>
        /// <param name="sqlBuilder">
        ///     An ISqlBuilder object which represents a SQL subquery on the right of the EXISTS operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhereExists(ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Adds the OR logical operator and a search condition to the WHERE clause; and uses the NOT EXISTS 
        ///     operator to test if the record returned from a subquery does not exist.
        /// </summary>
        /// <param name="sqlBuilder">
        ///     An ISqlBuilder object which represents a SQL subquery on the right of the NOT EXISTS operator.
        /// </param>
        /// <returns>
        ///     Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.
        /// </returns>
        TBuilder OrWhereNotExists(ISqlBuilder sqlBuilder);
    }
}
